﻿<!DOCTYPE html>
<html>
<!-- 个人安全行动计划管理 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW100" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">
            <el-row>
                <el-col :span="11">
                    <p class="main-label">{{PersonSafePlanManagement.year+mark.m}}</p>
                    <p class="lh35">{{Form.year}}</p>
                </el-col>
                <el-col :span="11" :offset="2">
                    <p class="main-label">{{PersonSafePlanManagement.quarter+mark.m}}</p>
                    <p v-if="Form.quarter==1" class="lh35">第一季度</p>
                    <p v-if="Form.quarter==2" class="lh35">第二季度</p>
                    <p v-if="Form.quarter==3" class="lh35">第三季度</p>
                    <p v-if="Form.quarter==4" class="lh35">第四季度</p>
                </el-col>

            </el-row>
            <!--<el-row>
        <el-col :span="11">
            <div class="elst-select-mini">
                <el-form-item prop="year">
                    <el-input type="text" v-model="Form.year" size="mini">
                        <template slot="prepend">
                            {{PersonSafePlanManagement.year+mark.m}}
                        </template>
                    </el-input>

                </el-form-item>
            </div>
        </el-col>
        <el-col :span="11"  :offset="2">
            <div class="elst-select-mini">
                <el-form-item>
                    <el-input size="mini">
                        <template slot="prepend">
                            {{PersonSafePlanManagement.quarter+mark.m}}
                        </template>

                        <el-select @visible-change="visibleChange" v-model="Form.quarter" slot="suffix" placeholder="请选择">
                            <el-option label="请选择" key="" value=""></el-option>
                            <el-option v-for="item in options"
                                       :key="item.value"
                                       :label="item.label"
                                       :value="item.value">
                            </el-option>
                        </el-select>
                    </el-input>
                </el-form-item>
            </div>

        </el-col>

    </el-row>-->

            <el-row>
                <!--<el-row>
            <el-col :span="24">
                <el-form-item>
                    <el-button type="primary" @click="add('ruleForm')">{{col.btnAdd}}</el-button>
                </el-form-item>
            </el-col>

        </el-row>-->
                <el-col :span="24" style="padding-bottom:10px">
                    <div class="elst-select-mini">
                        <el-table ref="table" :data="ListItem.jG_PersonalSafetyDetail" :row-key="getRowKeys" border
                                  @current-change="tableHandleCurrentChange" class="tb-edit" row-style="height:10px" style="width: 100%;">
                            <el-table-column prop="Project" :label="col.SequenceNumber" width="50">
                                <template slot-scope="props">
                                    {{props.$index + 1}}
                                </template>
                            </el-table-column>
                            <!--<el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"
                    show-overflow-tooltip="true"></el-table-column>-->

                            <el-table-column prop="planContent" :label="PersonSafePlanManagement.planMain">

                            </el-table-column>

                        </el-table>


                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="actualContent">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{PersonSafePlanManagement.actualContent+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.actualContent"
                                          autocomplete="off"></el-input>

                            </div>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="remarks">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{PersonSafePlanManagement.remarks+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.remarks"
                                          autocomplete="off"></el-input>

                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="8">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input disabled type="text" v-model="Form.attachmentName" autocomplete="off" size="mini"
                                      readonly>
                                <template slot="prepend">
                                    {{"面谈记录"+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">

                    <el-upload name="files" class="fl" ref="Attachmentupload" action="/api/File/UploadFile" multiple="true"
                               :before-upload="beforeUpload" :on-success="successUpLoad" :auto-upload="true"
                               :show-file-list="false">
                        <el-button type="primary">{{col.lawUploadAttachment}}</el-button>
                    </el-upload>
                </el-col>
            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>

                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
    </div>
    <script type="text/javascript">

        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                //文件上传接口路径
                UploadFileApiUrl: API_UPLOADFILE_URL,
                value1: '',
                // picked : '1',
                //父业传参
                id: '',
                //获取下拉菜单frequency
                ListItem: ListItem,
                options: [{
                    value: 1,
                    label: '第一季度'
                }, {
                        value: 2,
                        label: '第二季度'
                    }, {
                        value: 3,
                        label: '第三季度'
                    }, {
                        value: 4,
                        label: '第四季度'
                    }],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    year: '',
                    quarter: '',
                    ActualContent: '',
                    Remarks: '',
                    attachmentId: '',
                    attachmentName: uploadText,
                    State: '0',
                    jG_PersonalSafetyDetail: []
                },
                //表单验证
                rules: {
                    year: [
                        verification.NotNull,
                    ],
                    quarter: [
                        verification.NotNull,
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/JG_PersonalSafety/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                //onSubmitForm: function (formName, state) {

                //    var mythis = this;
                //    this.$refs[formName].validate(function (valid) {
                //        //验证通过
                //        if (valid) {
                //            mythis.Form.State = state;
                //            onSubmitForm(this, '/api/JG_PersonalSafety/Save', mythis.Form);
                //        } else {
                //            //验证失败
                //            return false;
                //        }
                //    });
                //},
                getData: function () {
                    getData(this, '/api/JG_PersonalSafety/get?id=' + this.id);
                    //this.Form.frequency = this.Form.frequency + "";
                },
                indexMethod: function (index) {
                    return index + 1;
                },
                // 行内编辑 js
                add: function (formName) {
                    if ($('tbody tr').attr("class") == "el-table__row current-row") {
                        showMessage(msg.EditingNotCompleted, 'error');
                    } else {

                        //this.Form.year = '';//添加是清空录入数据的，每一项都要有
                        //this.Form.quarter = '';//添加是清空录入数据的，每一项都要有
                        //this.Form.ActualContent = '';//添加是清空录入数据的，每一项都要有
                        //this.Form.Remarks = '';//添加是清空录入数据的，每一项都要有
                        $('.el-table__row').removeClass('current-row');
                        $('.el-table__row span.end').removeClass('xian');
                        $('.el-table__row span.end').addClass('yin');
                        $('.el-table__row span.start').removeClass('yin');
                        $('.el-table__row span.start').addClass('xian');
                        var newObj = {
                            planContent: ''
                        }
                        var sss = '';
                        this.ListItem.jG_PersonalSafetyDetail.unshift(newObj);
                        //this.ListItem.jG_PersonalSafetyDetail.unshift(this.Form);
                        setTimeout(function () {
                            $('.el-table__row:eq(0)').addClass('current-row');
                            $('.el-table__row:eq(0) span.end').removeClass('yin');
                            $('.el-table__row:eq(0) span.end').addClass('xian');
                            $('.el-table__row:eq(0) span.start').removeClass('xian');
                            $('.el-table__row:eq(0) span.start').addClass('yin');
                        }, 100);
                    }
                },
                //修改
                Edit: function (val, id, index) {
                    $('.el-table__row').removeClass('current-row');
                    $('.el-table__row:eq(' + index + ')').addClass('current-row');
                    $('.el-table__row span.end').removeClass('xian');
                    $('.el-table__row span.end').addClass('yin');
                    $('.el-table__row span.start').removeClass('yin');
                    $('.el-table__row span.start').addClass('xian');
                    $('.el-table__row:eq(' + index + ') span.end').removeClass('yin');
                    $('.el-table__row:eq(' + index + ') span.end').addClass('xian');
                    $('.el-table__row:eq(' + index + ') span.start').removeClass('xian');
                    $('.el-table__row:eq(' + index + ') span.start').addClass('yin');
                },
                // 保存  注意去掉mock中的parent 否则无法保存
                Save: function (a, b) {
                    if (!b.planContent) {
                        showMessage(msg.NoMust, 'error');
                    }
                    else {
                        $('.el-table__row').removeClass('current-row');
                        console.log("a", a);
                        console.log("b", b);
                        $('.el-table__row span.end').removeClass('xian');
                        $('.el-table__row span.end').addClass('yin');
                        $('.el-table__row span.start').removeClass('yin');
                        $('.el-table__row span.start').addClass('xian');
                        //初始化数据
                        // this.GetPageData(1);
                    }
                },
                Back: function (a, b) {
                    $('.el-table__row').removeClass('current-row');
                    $('.el-table__row span.end').removeClass('xian');
                    $('.el-table__row span.end').addClass('yin');
                    $('.el-table__row span.start').removeClass('yin');
                    $('.el-table__row span.start').addClass('xian');
                    //初始化数据
                    this.GetPageData(1);
                },
                handblur: function () {
                    //this.$refs.table.setCurrentRow(999);
                    //console.log("c", 'c');
                },
                //table选中行handle
                tableHandleCurrentChange: function (currentRow) {
                    this.currSeelctId = currentRow.id;
                    this.currSeelctCell = currentRow;
                },
                //删除列表行
                deleteRow: function (index, rows) {
                    rows.splice(index, 1);
                },
                // 行内编辑 js
                //上传前文件的校验
                beforeUpload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将文件名称赋值到label上
                    this.labelUpload = file.name;
                    const extension = testmsg === 'rar'
                    const extension1 = testmsg === 'zip'
                    const extension2 = testmsg === 'txt'
                    const extension3 = testmsg === 'jpg'
                    const extension4 = testmsg === 'jpeg'
                    const extension5 = testmsg === 'png'
                    const extension6 = testmsg === 'docx'
                    const extension7 = testmsg === 'doc'
                    const extension8 = testmsg === 'xlsx'
                    const extension9 = testmsg === 'xls'
                    const extension10 = testmsg === 'pdf'
                    const isLt10M = file.size / 1024 / 1024 < 10

                    if (!extension && !extension1 && !extension2 && !extension3 && !extension4 && !extension5 && !extension6 && !extension7 && !extension8 && !extension9 && !extension10) {
                        this.$message({
                            message: '上传格式不正确!',
                            type: 'warning'
                        });
                    }
                    if (!isLt10M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if ((extension || extension1 || extension2 || extension3 || extension4 || extension5 || extension6 || extension7 || extension8 || extension9 || extension10) && isLt10M)
                        submitUpload(this, 'upload')
                    return (extension || extension1 || extension2 || extension3 || extension4 || extension5 || extension6 || extension7 || extension8 || extension9 || extension10) && isLt10M
                },
                //上传成功后执行
                successUpLoad: function (res, file) {
                    var data = res.data;//成功后的业务数据
                    var fileModel = data[0];//第一个文件对象

                    this.Form.attachmentId = fileModel.id,
                        this.Form.attachmentName = fileModel.fileName;// downLoadPath(fileModel.id);
                    //this.fileAttachmentUpload = file.name;
                },
                ////上传附件文件的校验
                //fileAttachmentUploadbeforeupload: function (file) {
                //    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                //    //将附件名赋值到label上
                //    this.Form.attachmentName = file.name;
                //    const extension = testmsg === 'rar'
                //    const extension1 = testmsg === 'zip'
                //    const extension2 = testmsg === 'txt'
                //    const extension3 = testmsg === 'jpg'
                //    const extension4 = testmsg === 'jpeg'
                //    const extension5 = testmsg === 'png'
                //    const extension6 = testmsg === 'docx'
                //    const extension7 = testmsg === 'doc'
                //    const extension8 = testmsg === 'xlsx'
                //    const extension9 = testmsg === 'xls'
                //    const extension10 = testmsg === 'pdf'
                //    const isLt10M = file.size / 1024 / 1024 < 10
                //    if (!extension && !extension1 && !extension2 && !extension3 && !extension4 && !extension5 && !extension6 && !extension7 && !extension8 && !extension9 && !extension10) {
                //        this.$message({
                //            message: '上传文件格式不正确!',
                //            type: 'warning'
                //        });
                //    }
                //    if (!isLt10M) {
                //        this.$message({
                //            message: '上传文件大小不能超过 10MB!',
                //            type: 'warning'
                //        });
                //    }
                //    if ((extension || extension1 || extension2 || extension3 || extension4 || extension5 || extension6 || extension7 || extension8 || extension9 || extension10) && isLt10M)
                //        submitUpload(this, 'upload')
                //    return (extension || extension1 || extension2 || extension3 || extension4 || extension5 || extension6 || extension7 || extension8 || extension9 || extension10) && isLt10M
                //},
                //btnAttachmentUpload: function () {
                //    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                //    if (this.fileAttachmentUpload != uploadText) {
                //        this.$refs.Attachmentupload.clearFiles();
                //        this.fileAttachmentUpload = file.name;
                //    }
                //    else {

                //    }
                //    this.$refs.Attachmentupload.submit();
                //},
            },
            mounted: function () {
                this.id = getUrlParam("id");
                this.getData();
                //读取数据到表格数据对象
                this.ListItem.jG_PersonalSafetyDetail = this.Form.jG_PersonalSafetyDetail;
                ////获取下拉菜单内容
                //this.frequency = getDicData('n56');
                //初始化数据
                // this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
        });
    </script>
</body>

</html>